local ModalDialog = require("app.widget.ModalDialog")

local ActivityIndicator = class("ActivityIndicator",function() return ModalDialog.new() end)


function ActivityIndicator:ctor()
    -- local size = self:getContentSize()
    local node = cc.CSLoader:createNode(Res.ActivityIndicator,true)
    if node then
        node:setContentSize(display.width,display.height)
        self:addChild(node)
        ccui.Helper:doLayout(node)
        local timeline1 = node:getActionByTag(0)
        local timeline2 = nil
        
        local subNode = node:getChildByName("ProjectNode_1")
        if subNode then
            timeline2 = subNode:getActionByTag(0)
        end
        self.aniNodes = {timeline1,timeline2}

        node:setVisible(false)
        self._root = node
    else
        self.aniNodes = {}
    end
end

function ActivityIndicator:play()
    if self._root then
        self._root:setVisible(true)
    end
    self:setBackGroundColorOpacity(179)

    for _,v in pairs(self.aniNodes) do
        if v then
            v:gotoFrameAndPlay(0,true)
        end
    end
end

function ActivityIndicator:stop()
    if self._root then
        self._root:setVisible(false)
    end
    self:setBackGroundColorOpacity(0)

    for _,v in pairs(self.aniNodes) do
        if v then
            v:gotoFrameAndPause(0)
        end
    end
end

return ActivityIndicator